#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
	{                                         \
		cerr << "\033[32;1m" << #x << " -> "; \
		err(x);                               \
	}
void err()
{
	cerr << "\033[39;0m" << endl;
}
template <typename T, typename... A>
void err(T a, A... x)
{
	cerr << a << ' ';
	err(x...);
}
#else
#define dbg(...)
#endif

typedef long long LL;

const int N = 3e5 + 50;

struct node
{
	int u, v, w;
	node(int u = 0, int v = 0, int w = 0) : u(u), v(v), w(w) {}

} dat[N];

inline bool cmp(const node &a, const node &b)
{
	if (a.u != b.u)
		return a.u < b.u;
	else
		return a.v > b.v;
}

int n;

vector<int> G[N];

inline bool in(const node &a, const node &b)
{
	return a.u <= b.u && b.v <= a.v;
}

int siz[N], mson[N];

void dfs(int u)
{
	siz[u] = 1;
	int maxson = -1;
	for (int v : G[u])
	{
		dfs(v);
		if (maxson == -1 || siz[v] + 1 > siz[u])
		{
			siz[u] = siz[v] + 1;
			maxson = v;
		}
	}
	mson[u] = maxson;
}

typedef multiset<int, greater<int>> T;

T S[N];

int tmp[N], tcnt;
int tmp2[N], t2cnt;

void dfs2(int u)
{
	if (G[u].size() == 0)
	{
		S[u].insert(dat[u].w);
		return;
	}

	for (int v : G[u])
		dfs2(v);
	swap(S[u], S[mson[u]]);

	tcnt = 0;
	int mxm = 0;
	for (int v : G[u])
	{
		if (v != mson[u])
		{
			int tt = 0;
			for (int x : S[v])
			{
				if (tt == mxm)
				{
					tmp[mxm++] = 0;
				}
				tmp[tt++] += x;
			}
		}
	}
	int tt = 0;
	for (int x : S[u])
	{
		tmp2[tt++] = x;
		if (tt == mxm)
			break;
	}
	for (int i = 0; i < mxm; i++)
		S[u].erase(S[u].find(tmp2[i]));
	for (int i = 0; i < mxm; i++)
		S[u].insert(tmp[i] + tmp2[i]);
	S[u].insert(dat[u].w);
}

LL diff[N];

signed main()
{
	scanf("%lld", &n);
	for (int i = 1; i <= n; ++i)
	{
		scanf("%lld%lld%lld", &dat[i].u, &dat[i].v, &dat[i].w);
	}

	sort(dat + 1, dat + n + 1, cmp);
	int root = ++n;
	stack<int> s;
	dat[root] = node(0, 1e6 + 1, 0);
	s.push(root);
	for (int i = 1; i < n; ++i)
	{
		while (!s.empty() && !in(dat[s.top()], dat[i]))
			s.pop();
		int fa = s.top(), son = i;
		G[fa].push_back(son);
		s.push(i);
	}

	dfs(root);
	dfs2(root);

	int dcnt = 0;
	for (const auto x : (S[root]))
		diff[dcnt++] = x;
	for (int i = 1; i < dcnt; ++i)
		diff[i] += diff[i - 1];
	--dcnt;
	for (int i = dcnt; i < n - 1; ++i)
		diff[i] = diff[dcnt - 1];

	for (int i = 0; i < n - 1; ++i)
		printf("%lld%c", diff[i], i == n - 2 ? '\n' : ' ');

	return 0;
}